//
//  FilemViewController.m
//  Newproject3
//
//  Created by rimi on 16/9/22.
//  Copyright © 2016年 Liang. All rights reserved.
//

#import "FilemViewController.h"
#import "FilemTableViewCell.h"
#import "IntrouduceViewController.h"
static NSString *const CellID = @"FilemTableViewCell";
@interface FilemViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *filemTableView;
@end

@implementation FilemViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.filemTableView];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    FilemTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
    NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"plistdemo1" ofType:@"plist"];
    self.arrayData = [[NSMutableArray alloc] initWithContentsOfFile:plistPath];
    cell.filemImage.image = [UIImage imageNamed:self.arrayData[indexPath.row][@"image"]];
    cell.filemLable1.text = self.arrayData[indexPath.row][@"lable1"];
    cell.filemLable2.text = self.arrayData[indexPath.row][@"lable2"];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    IntrouduceViewController *vc = [[IntrouduceViewController alloc] init];
    ((IntrouduceViewController *)vc).dic = self.arrayData[indexPath.row];
    [self.navigationController pushViewController:vc animated:YES];
}
- (UITableView *)filemTableView{
    if (!_filemTableView) {
        _filemTableView = [[UITableView alloc] initWithFrame:self.view.frame];
        _filemTableView.rowHeight = 100;
        _filemTableView.delegate = self;
        _filemTableView.dataSource = self;
        [_filemTableView registerNib:[UINib nibWithNibName:@"FilemTableViewCell" bundle:nil] forCellReuseIdentifier:CellID];
    }
    return _filemTableView;
}

@end
